package com.janko.redislock;

import org.redisson.Redisson;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableCaching
public class RedisLockApp8080 {

    public static void main(String[] args) {
        SpringApplication.run(RedisLockApp8080.class, args);
    }

    /**
     * 初始化Redisson配置信息
     * @auth janko
     * @return
     */
    @Bean
    public Redisson redisson() {
        org.redisson.config.Config config = new org.redisson.config.Config();
        /**
         * 链接Redission的时候、Redis的密码必须不能为空.  不然会报错.
         */
        config.useSingleServer().setAddress("redis://127.0.0.1:6379").setDatabase(1).setPassword("123456");
        return (Redisson) Redisson.create(config);
    }
}
